
#ifndef   	__PHONE_NUMBERS_H_
#define   	__PHONE_NUMBERS_H_

#include "ext_e2_map.h"


#define   PHONE_NUMBERS_BCD_SIZE		7
#define   USER_PASSWORD_SIZE			7
#define   COUNT_OWNERS					20
#define   COUNT_USERS					80


#define   LIST_OWNERS					EX_ADDR_LIST_OWNERS
#define   LIST_USERS_GROUP_1			EX_ADDR_LIST_USERS_GROUP_1
#define   LIST_USERS_GROUP_2			EX_ADDR_LIST_USERS_GROUP_2
#define   LIST_USERS_GROUP_3			EX_ADDR_LIST_USERS_GROUP_3
#define   LIST_USERS_GROUP_4			EX_ADDR_LIST_USERS_GROUP_4

//#define   NO_FREE_ENTRY		(-1)
#define   NOT_FOUND			(-2)


/* enum */
/* { */
/* 	NO_FREE_ENTRY = 0xF0, */
/* 	 NOT_FOUND, 	   */
/* 	NUMBER_EXISTS */
/* }; */


typedef struct
{
		unsigned char Phone[PHONE_NUMBERS_BCD_SIZE];	  /* BCD format */
		unsigned char Reserve;
		/* Add new field */
		unsigned char UserPassword[USER_PASSWORD_SIZE];				  /* string format */
}RECORD_CUSTOMER;


// CR - Customer Record

int CR_Count( unsigned int Address );
unsigned char CR_DeleteAll( unsigned int Address );

/* Delete Customer Record; return: Address of deleted CR if successful, or (-1) if ERROR */
int CR_Delete ( unsigned int Address, unsigned char* PhoneNumber );

/* Add customer to the List; if the Phone exists - rewrite it; return: NO_FREE_ENTRY or TRUE  */
int CR_Add ( unsigned int Address, unsigned char* PhoneNumber );

int CR_Find( unsigned int Address, unsigned char* PhoneNumber );
int CR_FindFree( unsigned int Address );
//unsigned char CR_DeleteList( unsigned int List );



#if COUNT_USERS > EX_LIST_USERS_GROUP_1_COUNT_MAX
#error	 Too much: COUNT_USERS
#endif

#if COUNT_OWNERS > EX_LIST_OWNERS_COUNT_MAX
#error	 Too much: COUNT_OWNERS
#endif


#endif
